from sqlalchemy import Column
from sqlalchemy.sql.sqltypes import String, Integer, Text
from app.core.base_model import BaseModel


class FileProcessor(BaseModel):
    __tablename__ = 't_proc_file'
    file_name = Column(String(128), nullable=False)
    proc_type = Column(String(8), nullable=False)
    if_del = Column(String(2), default='0')
    proc_state = Column(String(8), nullable=False, default='0')
    proc_rows = Column(Integer)
    proc_result = Column(Text)
    db_str = Column(String(1024))
    db_type = Column(String(12), default='ORACLE')
    file_config_json = Column(Text)

    def __init__(self, file_name, proc_type, if_del, proc_state):
        self.file_name = file_name
        self.proc_type = proc_type
        self.if_del = if_del
        self.proc_state = proc_state  # 处理状态，默认0-初始状态

    def __repr__(self):
        return '[%r]%s' % (self.id, self.file_name)


class RptGenerator(BaseModel):
    __tablename__ = 't_proc_reports'
    rpt_type = Column(String(8), nullable=False)
    proc_state = Column(String(8), nullable=False, default='0')
    proc_result = Column(Text)

    def __init__(self, rpt_type, proc_state):
        self.rpt_type = rpt_type
        self.proc_state = proc_state  # 处理状态，默认0-初始状态

    def __repr__(self):
        return '[%r]%r' % (self.rpt_type, self.id)
